import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable, map } from 'rxjs';
import { AnyJson } from './data-types/common.type';
import { ServicesModule } from './services.module';

@Injectable({
  providedIn: ServicesModule,
})
export class SpeNewsService {
  constructor(private http: HttpClient) {}
  insertSpeNews(body: AnyJson): Observable<AnyJson> {
    return this.http
      .get('/speNews/insertSpeNews', body)
      .pipe(map((res) => res as AnyJson));
  }
  getSpeNewsMsgById(params: AnyJson): Observable<AnyJson> {
    return this.http
      .get('/speNews/getSpeNewsMsgById', { params })
      .pipe(map((res) => res as AnyJson));
  }
  updateSpeNews(body: AnyJson): Observable<AnyJson> {
    return this.http
      .get('/speNews/updateSpeNews', body)
      .pipe(map((res) => res as AnyJson));
  }
  likeNews(body: AnyJson, params: AnyJson): Observable<AnyJson> {
    return this.http
      .post('/speNews/likeNews', body, { params })
      .pipe(map((res) => res as AnyJson));
  }
  getSpeNewsTitleByLid(params: AnyJson, body: AnyJson): Observable<AnyJson> {
    return this.http
      .post('/speNews/getSpeNewsTitleByLid', body, { params })
      .pipe(map((res) => res as AnyJson));
  }
  clearSpeSortByLid(params: AnyJson): Observable<AnyJson> {
    return this.http
      .get('/speNews/clearSpeSortByLid', { params })
      .pipe(map((res) => res as AnyJson));
  }
  delSpeNews(params: AnyJson): Observable<AnyJson> {
    return this.http
      .get('/speNews/delSpeNews', { params })
      .pipe(map((res) => res as AnyJson));
  }

  getSpeNewsLableTitleByLid(params: AnyJson): Observable<AnyJson> {
    return this.http
      .get('/speNewsLable/getSpeNewsTitleByLid', { params })
      .pipe(map((res) => res as AnyJson));
  }
}
